<template>
  <el-container class="home_container">
    <!-- 头部区域 -->
    <el-header>
      <div class="home_img">
        <img src="../assets/girl.jpg" alt="" />
        <span>数据分析平台</span>
      </div>
      <el-button type="info" @click="logout">退出</el-button>
    </el-header>
    <!-- 页面主体区域 -->
    <el-container>
      <!-- 侧边栏 -->
      <el-aside width="200px">
        <!-- 侧边栏菜单区域 -->
        <el-menu
          :default-active="activePath"
          background-color="#333744"
          text-color="#fff"
          active-text-color="#ffd04b"
          router
        >
          <!-- 一级菜单 -->
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>调度计划</span>
            </template>
            <!-- 二级菜单 -->
            <el-menu-item index="/DdjhDa" @click="saveNavState('/DdjhDa')"
              >日前计划运行监视</el-menu-item
            >
          </el-submenu>

          <!-- 一级菜单 -->
          <el-submenu index="2">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>负荷预测</span>
            </template>
            <!-- 二级菜单 -->
            <el-menu-item index="/FhycSt" @click="saveNavState('/FhycSt')"
              >地调系统负荷预测</el-menu-item
            >
          </el-submenu>

          <!-- 一级菜单 -->
          <el-submenu index="3">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>省间现货</span>
            </template>
            <!-- 二级菜单 -->
            <el-menu-item index="/SjxhDa" @click="saveNavState('/SjxhDa')"
              >日前交易</el-menu-item
            >
          </el-submenu>
        </el-menu>
      </el-aside>
      <!-- 右侧内容 -->
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  data() {
    return {
      // 被激活的链接地址
      activePath: "",
    };
  },
  components: {
    // DdjhDa,
  },
  methods: {
    logout() {
      window.sessionStorage.clear();
      this.$router.push("/login");
    },
    // 保存链接的激活状态
    saveNavState(activePath) {
      window.sessionStorage.setItem("activePath", activePath);
      this.activePath = activePath;
    },
  },
  created() {
    this.activePath = window.sessionStorage.getItem("activePath");
  },
};
</script>

<style scoped>
.home_container {
  height: 100%;
}
.el-header {
  background-color: #373d41;
  display: flex;
  justify-content: space-between;
  padding-left: 0px;
  align-items: center;
  color: #fff;
  font-size: 20px;
  font-family: "宋体";
}
.home_img img {
  height: 56px;
  width: 61px;
  border-radius: 50%;
}
.home_img {
  display: flex;
  align-items: center;
}
.home_img span {
  margin-left: 15px;
}
.el-aside {
  background-color: #333744;
}
.el-main {
  background-color: #eaedf1;
}
</style>